/*
 * Powered By [Frank-Liz-Lee]
 * Copyright(C) 2012-2016 Liz Company
 * All rights reserved.
 */

package com.linln.modules.system.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.linln.modules.system.mapper.FileMapper;
import com.linln.modules.system.domain.File;
import java.util.List;

import com.linln.modules.system.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional(rollbackFor = Exception.class)
@Service
public class FileServiceImpl  extends GenericService<File, Long>  implements FileService {

    private FileMapper fileMapper;

    @Autowired
    public void setFileMapper(FileMapper fileMapper) {
        this.fileMapper = fileMapper;
    }

    /**
     * 通过主键查询实体对象
     * @param primaryKey
     * @return
     * @
     */
    public File getByPK(Long primaryKey)  {
        return fileMapper.getByPK(primaryKey);
    }

    /**
     * 查询所有记录
     * @return
     * @
     */
    public List<File> list()  {
        return fileMapper.list();
    }

    /**
     * 根据查询条件查询所有记录
     * @return
     * @
     */
    public List<File> listByProperty(File file) {
        return fileMapper.listByProperty(file);
    }


    /**
     * 根据主键删除记录
     * @param primaryKey
     * @return
     * @
     */
    public int deleteByPK(Long primaryKey)  {
        return fileMapper.deleteByPK(primaryKey);
    }

    /**
     * 根据多个主键删除记录
     * @param primaryKeys
     * @
     */
    public int deleteByPKeys(List<Long> primaryKeys)  {
        return fileMapper.deleteByPKeys(primaryKeys);
    }

    /**
     * 根据传入参数删除记录
     * @param file
     * @return
     * @
     */
    public int deleteByProperty(File file)  {
        return fileMapper.deleteByProperty(file);
    }

    /**
     * 保存记录
     * @param file
     * @return
     * @
     */
    public int save(File file)  {
        return fileMapper.save(file);
    }

    /**
     * 更新记录
     * @param file
     * @return
     * @
     */
    public int update(File file) {
        return fileMapper.update(file);
    }

    /**
     * 根据条件查询记录条数
     * @param file
     * @return
     * @
     */
    public int findByCount(File file)  {
        return fileMapper.findByCount(file);
    }

    /**
     * 根据查询条件查询分页记录
     * @return
     */
    public PageInfo<File> findByPage(Integer pageNum, Integer pageSize, File file) {
        PageHelper.startPage(pageNum,pageSize);
        List<File> fileList = fileMapper.listByProperty(file);
        if(null == fileList || fileList.size() == 0){
            return new Page<File>().toPageInfo();
        }
        Page<File> page =  (Page<File>)fileList;
            return page.toPageInfo();
    }
}
